import request from "@/utils/request"
const BASE_URL = process.env.VUE_APP_BASE_URL

// export function roleListFun(data) {
//   return request({
//     url: BASE_URL + 'adminRole/getAllRoleList',
//     method: 'post',
//     data: data
//   })
// }

// export function rulesList(data) {
//   return request({
//     url: BASE_URL + 'adminMenu/getAllMenuList',
//     method: 'post',
//     data: data
//   })
// }

export function roleAddAPI(data) {
	return request({
		url: BASE_URL + "adminRole/add",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 项目管理添加角色
 * @param {*} data
 * @returns
 */
export function addProjectRoleAPI(data) {
	return request({
		url: BASE_URL + "adminRole/addProjectRole",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

export function roleDeleteAPI(data) {
	return request({
		url: BASE_URL + "adminRole/delete",
		method: "post",
		data: data
	})
}

export function roleUpdateAPI(data) {
	return request({
		url: BASE_URL + "adminRole/update",
		method: "post",
		data: data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

export function updateRoleMenuAPI(data) {
	return request({
		url: BASE_URL + "adminRole/updateRoleMenu",
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		},
		data: data
	})
}

/**
 * 角色复制
 * @param {*} data
 */
export function roleCopyAPI(data) {
	return request({
		url: BASE_URL + "adminRole/copy",
		method: "post",
		data: data
	})
}

/**
 * 复制员工角色
 * @param {*} data
 */
export function adminRoleRelatedDeptUserAPI(data) {
	return request({
		url: BASE_URL + "adminRole/relatedDeptUser",
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		},
		data: data
	})
}

/**
 * 添加编辑员工
 * @param {*} data
 */
export function adminRoleRelatedUserAPI(data) {
	return request({
		url: BASE_URL + "adminRole/relatedUser",
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		},
		data: data
	})
}

/**
 * 删除员工
 * @param {*} data
 */
export function unbindingUserAPI(data) {
	return request({
		url: BASE_URL + "adminRole/unbindingUser",
		method: "post",
		data: data
	})
}

/**
 * 角色分类列表
 * @param {*} data
 */
export function adminGroupsTypeListAPI(data) {
	return request({
		url: BASE_URL + "adminRole/getRoleTypeList",
		method: "post",
		data: data
	})
}

/**
 * 参数 roleType   根据角色类型查询角色列表
 * @param {*} roleType
 */
export function systemRoleByTypeAPI(roleType) {
	return request({
		url: BASE_URL + `adminRole/getRoleByType/${roleType}`,
		method: "post"
	})
}

/**
 * @description: 角色列表排序
 * @param {*} data
 * @return {*}
 */
export function systemRoleListSortAPI(data) {
	return request({
		url: BASE_URL + "adminRole/setSorting",
		method: "post",
		data,
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		}
	})
}

/**
 * 规则
 * @param {*} roleType
 */
export function systemRuleByTypeAPI(roleType) {
	return request({
		url: BASE_URL + `adminMenu/getMenuListByType/${roleType}`,
		method: "post"
	})
}

/**
 * 查询字段授权设置
 * @param {*} data
 */
export function systemRoleGetFieldAPI(data) {
	return request({
		url: BASE_URL + "crmField/queryRoleField",
		method: "post",
		data: data
	})
}
/**
 * scrm查询字段授权设置
 * @param {*} data
 */
export function systemScrmRoleGetFieldAPI(data) {
	return request({
		url: BASE_URL + "scrmField/queryRoleField",
		method: "post",
		data: data
	})
}
/**
 * 模块设置字段授权
 * @param {*} data
 */
export function systemRoleSetFieldAPI(data) {
	return request({
		url: BASE_URL + "crmField/saveRoleField",
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		},
		data: data
	})
}
/**
 * 模块设置字段授权
 * @param {*} data
 */
export function systemScrmRoleSetFieldAPI(data) {
	return request({
		url: BASE_URL + "scrmField/saveRoleField",
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		},
		data: data
	})
}

/**
 * 通过 userId 批量查询用户的角色
 * @param {*} data
 */
export function adminRoleQueryUserRoleAPI(data) {
	return request({
		url: BASE_URL + "adminRole/roles/users",
		method: "post",
		headers: {
			"Content-Type": "application/json;charset=UTF-8"
		},
		data: data
	})
}
